package org.sixtynine.stock.service.impl;

import java.util.List;

import org.sixtynine.stock.dao.PackageDataDao;
import org.sixtynine.stock.dto.GridPramDTO;
import org.sixtynine.stock.dto.Page;
import org.sixtynine.stock.entity.PackageData;
import org.sixtynine.stock.service.PackageDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author Thilan
 * 
 */

@Service
public class PackageDataServiceImpl implements PackageDataService {

	@Autowired
	private PackageDataDao packageDao;

	@Override
	public PackageData findById(int id) {
		return packageDao.findById(id);
	}

	@Override
	@Transactional(readOnly = false)
	public void savePackageData(PackageData packageData) {
		packageDao.savePackageData(packageData);
	}

	@Override
	@Transactional(readOnly = false)
	public void deletePackageData(int id) {
		PackageData packageData = packageDao.findById(id);
		if (packageData != null) {
			packageDao.delete(packageData);
		}
	}

	@Override
	public PackageData searchPackageData(String name) {
		return packageDao.findPackageData(name);
	}

	@Override
	public List<PackageData> searchPackageData(int duration) {
		return packageDao.findPackageData(duration);
	}

	@Override
	public Page<PackageData> searchPackageData(int duration, String name,
			String orderBy, String orderName, GridPramDTO gridPramDTO) {
		return packageDao.searchPackageData(duration, name, orderBy, orderName,
				gridPramDTO);

	}

}
